// API基础URL配置
const BASE_URL = 'http://localhost:48080/app-api' // 请根据实际后端地址修改

// 统一的请求方法
export const request = (options) => {
    return new Promise((resolve, reject) => {
        uni.request({
            url: BASE_URL + options.url,
            method: options.method || 'GET',
            data: options.data || {},
            header: {
                'Content-Type': 'application/json',
                'tenant-id': '1',
                'authorization': 'Bearer 029f445e347d40beb2dc9fc28e3063c1',
                'login_user_type': '1',
                ...options.header
            },
            success: (res) => {
                if (res.statusCode === 200) {
                    resolve(res.data)
                } else {
                    reject(res.data)
                }
            },
            fail: (error) => {
                reject(error)
            }
        })
    })
}
